<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>fetch</title>
    <link rel="stylesheet" href="../../model/element.css">
    <link rel="stylesheet" href="../../model/jsFn.css">
</head>
<body>
<div class="catalog">
    <h1>目录</h1>
    <ul>
        <li>
            <p><a href="#profile">fetch</a></p>
            <ul>
                <li><p><a href="#jsFn_fetch">fetch()</a></p></li>
            </ul>
        </li>
    </ul>
</div>
<div id="profile">
    <h2>对象简介:</h2>
    <p>fetch</p>
</div>
<!--对象的某一个方法-->
<div class="jsFnModel" id="jsFn_fetch">
    <h3>fetch:</h3>
    <div class="shape">
        <h3>函数使用样式</h3>
        <p>fetch(url,[options]) ->promise</p>
    </div>
    <div class="profile">
        <h3>函数功能简介</h3>
        <p>联网请求,和web里的fetch类似</p>
    </div>
    <div class="version" style="background: #c3c363">
        <p>稳定性;1 - 不稳定的</p>
        <p>新增于:v0.0.0</p>
    </div>
    <div class="params">
        <h3>参数列表:</h3>
        <ul>
            <li>
                <p>url</p>
                <p>&nbsp;string&nbsp;</p>
                <p>请求地址</p>
            </li>
            <li>
                <p>options</p>
                <p>&nbsp;object&nbsp;</p>
                <ul>
                    <li>
                        <p>options.headers:object--请求头</p>
                    </li>
                    <li>
                        <p>options.method:string--请求方式  "POST"|"GET"</p>
                    </li>
                    <li>
                        <p>options.body:object--发送请求的内容,默认{}</p>
                    </li>
                </ul>
            </li>
        </ul>
    </div>
    <div class="res">
        <h3>返回值:</h3>
        <p>promise</p>
        <p>需要继续执行.json(),才能得到数据</p>
    </div>
    <div class="code">
        <h3>例子</h3>
        <pre>
            <code>
                fetch('baseApi/user',{
                    headers:{
                        'Accept': 'application/json',
                        'Content-Type': 'text/plain',
                        'Accept-Charset': 'UTF-8'
                    },
                    method:"POST",
                    data:JSON.stringify({})
                }).then(res=>res.json()).then(res=>{
                    console.log(res);
                })
            </code>
        </pre>
    </div>
    <div class="error">
        <h3>抛出错误</h3>
    </div>
</div>
<div class="author">
    <p>by-草草</p>
</div>
</body>
</html>